package com.example.housecommon.utils;

import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import org.springframework.util.DigestUtils;

import java.nio.charset.Charset;

/**
 * @author ：Anitaxiaofeng
 * @description：
 * @create 2018-05-27
 **/
public class HashUtils {

//    private static final String salt = "mooc&comsuid&";
//
//    public static String getMD5(String passwd) {
//        String base = passwd + "/" + salt;
//        String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
//        return md5;
//    }



    private static final HashFunction FUNCTION = Hashing.md5();

    private static final String SALT = "mooc.com";

    public static String encryPassword(String password) {
        HashCode hashCode = FUNCTION.hashString(password+SALT, Charset.forName("UTF-8"));
        return hashCode.toString();
    }

}



